package com.jsptags.navigation.pager.parser;

import java.io.*;
import java.util.Hashtable;
import java.util.Vector;

public class TagExportParser implements TagExportParserConstants {

	private static Hashtable pagerTagExportCache = new Hashtable();
	private static Hashtable indexTagExportCache = new Hashtable();
	private static Hashtable pageTagExportCache = new Hashtable();
	public TagExportParserTokenManager token_source;
	JavaCharStream jj_input_stream;
	public Token token;
	public Token jj_nt;
	private int jj_ntk;
	private int jj_gen;
	private final int jj_la1[];
	private final int jj_la1_0[];
	private Vector jj_expentries;
	private int jj_expentry[];
	private int jj_kind;

	public static PagerTagExport parsePagerTagExport(String s)
			throws ParseException {
		Hashtable hashtable = pagerTagExportCache;
		PagerTagExport pagertagexport;
		pagertagexport = (PagerTagExport) pagerTagExportCache.get(s);
		if (pagertagexport == null) {
			StringReader stringreader = new StringReader(s);
			TagExportParser tagexportparser = new TagExportParser(stringreader);
			pagertagexport = tagexportparser.parsePagerTagExport();
			pagerTagExportCache.put(s, pagertagexport);
		}
		return pagertagexport;
	}

	public static IndexTagExport parseIndexTagExport(String s)
			throws ParseException {
		Hashtable hashtable = indexTagExportCache;

		IndexTagExport indextagexport;
		indextagexport = (IndexTagExport) indexTagExportCache.get(s);
		if (indextagexport == null) {
			StringReader stringreader = new StringReader(s);
			TagExportParser tagexportparser = new TagExportParser(stringreader);
			indextagexport = tagexportparser.parseIndexTagExport();
			indexTagExportCache.put(s, indextagexport);
		}
		return indextagexport;
	}

	public static PageTagExport parsePageTagExport(String s)
			throws ParseException {
		Hashtable hashtable = pageTagExportCache;

		PageTagExport pagetagexport;
		pagetagexport = (PageTagExport) pageTagExportCache.get(s);
		if (pagetagexport == null) {
			StringReader stringreader = new StringReader(s);
			TagExportParser tagexportparser = new TagExportParser(stringreader);
			pagetagexport = tagexportparser.parsePageTagExport();
			pageTagExportCache.put(s, pagetagexport);
		}
		return pagetagexport;
	}

	public final PagerTagExport parsePagerTagExport() throws ParseException {
		PagerTagExport pagertagexport = new PagerTagExport();
		token_source.SwitchTo(1);
		pagerExportDeclaration(pagertagexport);
		jj_consume_token(0);
		return pagertagexport;
	}

	public final void pagerExportDeclaration(PagerTagExport pagertagexport)
			throws ParseException {
		label0: do {
			pagerExportList(pagertagexport);
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 9: // '\t'
			case 10: // '\n'
			case 11: // '\013'
			case 12: // '\f'
			case 13: // '\r'
			case 27: // '\033'
				break;

			case 14: // '\016'
			case 15: // '\017'
			case 16: // '\020'
			case 17: // '\021'
			case 18: // '\022'
			case 19: // '\023'
			case 20: // '\024'
			case 21: // '\025'
			case 22: // '\026'
			case 23: // '\027'
			case 24: // '\030'
			case 25: // '\031'
			case 26: // '\032'
			default:
				jj_la1[0] = jj_gen;
				break label0;
			}
		} while (true);
	}

	public final void pagerExportList(PagerTagExport pagertagexport)
			throws ParseException {
		pagerExport(pagertagexport);
		label0: do
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			default:
				jj_la1[1] = jj_gen;
				break label0;

			case 7: // '\007'
				jj_consume_token(7);
				pagerExport(pagertagexport);
				break;
			}
		while (true);
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 8: // '\b'
			jj_consume_token(8);
			break;

		default:
			jj_la1[2] = jj_gen;
			break;
		}
	}

	public final void pagerExport(PagerTagExport pagertagexport)
			throws ParseException {
		Object obj = null;
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 10: // '\n'
		case 13: // '\r'
			Token token1;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 10: // '\n'
				token1 = jj_consume_token(10);
				break;

			case 13: // '\r'
				token1 = jj_consume_token(13);
				break;

			case 11: // '\013'
			case 12: // '\f'
			default:
				jj_la1[3] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagertagexport.setPageOffset(token1.image);
			break;

		case 9: // '\t'
		case 11: // '\013'
		case 12: // '\f'
			Token token2;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 11: // '\013'
				token2 = jj_consume_token(11);
				break;

			case 9: // '\t'
				token2 = jj_consume_token(9);
				break;

			case 12: // '\f'
				token2 = jj_consume_token(12);
				break;

			case 10: // '\n'
			default:
				jj_la1[4] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagertagexport.setPageNumber(token2.image);
			break;

		case 27: // '\033'
			Token token3 = jj_consume_token(27);
			jj_consume_token(6);
			pagerVar(pagertagexport, token3);
			break;

		case 14: // '\016'
		case 15: // '\017'
		case 16: // '\020'
		case 17: // '\021'
		case 18: // '\022'
		case 19: // '\023'
		case 20: // '\024'
		case 21: // '\025'
		case 22: // '\026'
		case 23: // '\027'
		case 24: // '\030'
		case 25: // '\031'
		case 26: // '\032'
		default:
			jj_la1[5] = jj_gen;
			jj_consume_token(-1);
			throw new ParseException();
		}
	}

	public final void pagerVar(PagerTagExport pagertagexport, Token token1)
			throws ParseException {
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 10: // '\n'
		case 13: // '\r'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 10: // '\n'
				jj_consume_token(10);
				break;

			case 13: // '\r'
				jj_consume_token(13);
				break;

			case 11: // '\013'
			case 12: // '\f'
			default:
				jj_la1[6] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagertagexport.setPageOffset(token1.image);
			break;

		case 9: // '\t'
		case 11: // '\013'
		case 12: // '\f'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 11: // '\013'
				jj_consume_token(11);
				break;

			case 9: // '\t'
				jj_consume_token(9);
				break;

			case 12: // '\f'
				jj_consume_token(12);
				break;

			case 10: // '\n'
			default:
				jj_la1[7] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagertagexport.setPageNumber(token1.image);
			break;

		default:
			jj_la1[8] = jj_gen;
			jj_consume_token(-1);
			throw new ParseException();
		}
	}

	public final IndexTagExport parseIndexTagExport() throws ParseException {
		IndexTagExport indextagexport = new IndexTagExport();
		token_source.SwitchTo(2);
		indexExportDeclaration(indextagexport);
		jj_consume_token(0);
		return indextagexport;
	}

	public final void indexExportDeclaration(IndexTagExport indextagexport)
			throws ParseException {
		label0: do {
			indexExportList(indextagexport);
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 14: // '\016'
			case 15: // '\017'
			case 16: // '\020'
			case 17: // '\021'
			case 27: // '\033'
				break;

			case 18: // '\022'
			case 19: // '\023'
			case 20: // '\024'
			case 21: // '\025'
			case 22: // '\026'
			case 23: // '\027'
			case 24: // '\030'
			case 25: // '\031'
			case 26: // '\032'
			default:
				jj_la1[9] = jj_gen;
				break label0;
			}
		} while (true);
	}

	public final void indexExportList(IndexTagExport indextagexport)
			throws ParseException {
		indexExport(indextagexport);
		label0: do
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			default:
				jj_la1[10] = jj_gen;
				break label0;

			case 7: // '\007'
				jj_consume_token(7);
				indexExport(indextagexport);
				break;
			}
		while (true);
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 8: // '\b'
			jj_consume_token(8);
			break;

		default:
			jj_la1[11] = jj_gen;
			break;
		}
	}

	public final void indexExport(IndexTagExport indextagexport)
			throws ParseException {
		Object obj = null;
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 14: // '\016'
		case 15: // '\017'
			Token token1;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 15: // '\017'
				token1 = jj_consume_token(15);
				break;

			case 14: // '\016'
				token1 = jj_consume_token(14);
				break;

			default:
				jj_la1[12] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			indextagexport.setItemCount(token1.image);
			break;

		case 16: // '\020'
		case 17: // '\021'
			Token token2;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 17: // '\021'
				token2 = jj_consume_token(17);
				break;

			case 16: // '\020'
				token2 = jj_consume_token(16);
				break;

			default:
				jj_la1[13] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			indextagexport.setPageCount(token2.image);
			break;

		case 27: // '\033'
			Token token3 = jj_consume_token(27);
			jj_consume_token(6);
			indexVar(indextagexport, token3);
			break;

		case 18: // '\022'
		case 19: // '\023'
		case 20: // '\024'
		case 21: // '\025'
		case 22: // '\026'
		case 23: // '\027'
		case 24: // '\030'
		case 25: // '\031'
		case 26: // '\032'
		default:
			jj_la1[14] = jj_gen;
			jj_consume_token(-1);
			throw new ParseException();
		}
	}

	public final void indexVar(IndexTagExport indextagexport, Token token1)
			throws ParseException {
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 14: // '\016'
		case 15: // '\017'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 15: // '\017'
				jj_consume_token(15);
				break;

			case 14: // '\016'
				jj_consume_token(14);
				break;

			default:
				jj_la1[15] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			indextagexport.setItemCount(token1.image);
			break;

		case 16: // '\020'
		case 17: // '\021'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 17: // '\021'
				jj_consume_token(17);
				break;

			case 16: // '\020'
				jj_consume_token(16);
				break;

			default:
				jj_la1[16] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			indextagexport.setPageCount(token1.image);
			break;

		default:
			jj_la1[17] = jj_gen;
			jj_consume_token(-1);
			throw new ParseException();
		}
	}

	public final PageTagExport parsePageTagExport() throws ParseException {
		PageTagExport pagetagexport = new PageTagExport();
		token_source.SwitchTo(3);
		pageExportDeclaration(pagetagexport);
		jj_consume_token(0);
		return pagetagexport;
	}

	public final void pageExportDeclaration(PageTagExport pagetagexport)
			throws ParseException {
		label0: do {
			pageExportList(pagetagexport);
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 18: // '\022'
			case 19: // '\023'
			case 20: // '\024'
			case 21: // '\025'
			case 22: // '\026'
			case 23: // '\027'
			case 24: // '\030'
			case 25: // '\031'
			case 26: // '\032'
			case 27: // '\033'
				break;

			default:
				jj_la1[18] = jj_gen;
				break label0;
			}
		} while (true);
	}

	public final void pageExportList(PageTagExport pagetagexport)
			throws ParseException {
		pageExport(pagetagexport);
		label0: do
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			default:
				jj_la1[19] = jj_gen;
				break label0;

			case 7: // '\007'
				jj_consume_token(7);
				pageExport(pagetagexport);
				break;
			}
		while (true);
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 8: // '\b'
			jj_consume_token(8);
			break;

		default:
			jj_la1[20] = jj_gen;
			break;
		}
	}

	public final void pageExport(PageTagExport pagetagexport)
			throws ParseException {
		Object obj = null;
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 25: // '\031'
		case 26: // '\032'
			Token token1;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 26: // '\032'
				token1 = jj_consume_token(26);
				break;

			case 25: // '\031'
				token1 = jj_consume_token(25);
				break;

			default:
				jj_la1[21] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setPageUrl(token1.image);
			break;

		case 22: // '\026'
		case 23: // '\027'
		case 24: // '\030'
			Token token2;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 23: // '\027'
				token2 = jj_consume_token(23);
				break;

			case 22: // '\026'
				token2 = jj_consume_token(22);
				break;

			case 24: // '\030'
				token2 = jj_consume_token(24);
				break;

			default:
				jj_la1[22] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setPageNumber(token2.image);
			break;

		case 18: // '\022'
		case 19: // '\023'
			Token token3;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 18: // '\022'
				token3 = jj_consume_token(18);
				break;

			case 19: // '\023'
				token3 = jj_consume_token(19);
				break;

			default:
				jj_la1[23] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setFirstItem(token3.image);
			break;

		case 20: // '\024'
		case 21: // '\025'
			Token token4;
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 20: // '\024'
				token4 = jj_consume_token(20);
				break;

			case 21: // '\025'
				token4 = jj_consume_token(21);
				break;

			default:
				jj_la1[24] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setLastItem(token4.image);
			break;

		case 27: // '\033'
			Token token5 = jj_consume_token(27);
			jj_consume_token(6);
			pageVar(pagetagexport, token5);
			break;

		default:
			jj_la1[25] = jj_gen;
			jj_consume_token(-1);
			throw new ParseException();
		}
	}

	public final void pageVar(PageTagExport pagetagexport, Token token1)
			throws ParseException {
		switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
		case 25: // '\031'
		case 26: // '\032'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 26: // '\032'
				jj_consume_token(26);
				break;

			case 25: // '\031'
				jj_consume_token(25);
				break;

			default:
				jj_la1[26] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setPageUrl(token1.image);
			break;

		case 22: // '\026'
		case 23: // '\027'
		case 24: // '\030'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 23: // '\027'
				jj_consume_token(23);
				break;

			case 22: // '\026'
				jj_consume_token(22);
				break;

			case 24: // '\030'
				jj_consume_token(24);
				break;

			default:
				jj_la1[27] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setPageNumber(token1.image);
			break;

		case 18: // '\022'
		case 19: // '\023'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 18: // '\022'
				jj_consume_token(18);
				break;

			case 19: // '\023'
				jj_consume_token(19);
				break;

			default:
				jj_la1[28] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setFirstItem(token1.image);
			break;

		case 20: // '\024'
		case 21: // '\025'
			switch (jj_ntk != -1 ? jj_ntk : jj_ntk()) {
			case 20: // '\024'
				jj_consume_token(20);
				break;

			case 21: // '\025'
				jj_consume_token(21);
				break;

			default:
				jj_la1[29] = jj_gen;
				jj_consume_token(-1);
				throw new ParseException();
			}
			pagetagexport.setLastItem(token1.image);
			break;

		default:
			jj_la1[30] = jj_gen;
			jj_consume_token(-1);
			throw new ParseException();
		}
	}

	public void ReInit(InputStream inputstream) {
		jj_input_stream.ReInit(inputstream, 1, 1);
		token_source.ReInit(jj_input_stream);
		token = new Token();
		jj_ntk = -1;
		jj_gen = 0;
		for (int i = 0; i < 31; i++)
			jj_la1[i] = -1;

	}

	public void ReInit(Reader reader) {
		jj_input_stream.ReInit(reader, 1, 1);
		token_source.ReInit(jj_input_stream);
		token = new Token();
		jj_ntk = -1;
		jj_gen = 0;
		for (int i = 0; i < 31; i++)
			jj_la1[i] = -1;

	}

	public void ReInit(TagExportParserTokenManager tagexportparsertokenmanager) {
		token_source = tagexportparsertokenmanager;
		token = new Token();
		jj_ntk = -1;
		jj_gen = 0;
		for (int i = 0; i < 31; i++)
			jj_la1[i] = -1;

	}

	private final Token jj_consume_token(int i) throws ParseException {
		Token token1;
		if ((token1 = token).next != null)
			token = token.next;
		else
			token = token.next = token_source.getNextToken();
		jj_ntk = -1;
		if (token.kind == i) {
			jj_gen++;
			return token;
		} else {
			token = token1;
			jj_kind = i;
			throw generateParseException();
		}
	}

	public final Token getNextToken() {
		if (token.next != null)
			token = token.next;
		else
			token = token.next = token_source.getNextToken();
		jj_ntk = -1;
		jj_gen++;
		return token;
	}

	public final Token getToken(int i) {
		Token token1 = token;
		for (int j = 0; j < i; j++)
			if (token1.next != null)
				token1 = token1.next;
			else
				token1 = token1.next = token_source.getNextToken();

		return token1;
	}

	private final int jj_ntk() {
		if ((jj_nt = token.next) == null)
			return jj_ntk = (token.next = token_source.getNextToken()).kind;
		else
			return jj_ntk = jj_nt.kind;
	}

	public final ParseException generateParseException() {
		jj_expentries.removeAllElements();
		boolean aflag[] = new boolean[30];
		for (int i = 0; i < 30; i++)
			aflag[i] = false;

		if (jj_kind >= 0) {
			aflag[jj_kind] = true;
			jj_kind = -1;
		}
		for (int j = 0; j < 31; j++)
			if (jj_la1[j] == jj_gen) {
				for (int l = 0; l < 32; l++)
					if ((jj_la1_0[j] & 1 << l) != 0)
						aflag[l] = true;

			}

		for (int k = 0; k < 30; k++)
			if (aflag[k]) {
				jj_expentry = new int[1];
				jj_expentry[0] = k;
				jj_expentries.addElement(jj_expentry);
			}

		int ai[][] = new int[jj_expentries.size()][];
		for (int i1 = 0; i1 < jj_expentries.size(); i1++)
			ai[i1] = (int[]) jj_expentries.elementAt(i1);

		return new ParseException(token, ai,
				TagExportParserConstants.tokenImage);
	}

	public final void enable_tracing() {
	}

	public final void disable_tracing() {
	}

	public TagExportParser(InputStream inputstream) {
		jj_la1 = new int[31];
		jj_la1_0 = (new int[] { 0x8003e00, 128, 256, 9216, 6656, 0x8003e00,
				9216, 6656, 15872, 0x803c000, 128, 256, 49152, 0x30000,
				0x803c000, 49152, 0x30000, 0x3c000, 0xffc0000, 128, 256,
				0x6000000, 0x1c00000, 0xc0000, 0x300000, 0xffc0000, 0x6000000,
				0x1c00000, 0xc0000, 0x300000, 0x7fc0000 });
		jj_expentries = new Vector();
		jj_kind = -1;
		jj_input_stream = new JavaCharStream(inputstream, 1, 1);
		token_source = new TagExportParserTokenManager(jj_input_stream);
		token = new Token();
		jj_ntk = -1;
		jj_gen = 0;
		for (int i = 0; i < 31; i++)
			jj_la1[i] = -1;

	}

	public TagExportParser(Reader reader) {
		jj_la1 = new int[31];
		jj_la1_0 = (new int[] { 0x8003e00, 128, 256, 9216, 6656, 0x8003e00,
				9216, 6656, 15872, 0x803c000, 128, 256, 49152, 0x30000,
				0x803c000, 49152, 0x30000, 0x3c000, 0xffc0000, 128, 256,
				0x6000000, 0x1c00000, 0xc0000, 0x300000, 0xffc0000, 0x6000000,
				0x1c00000, 0xc0000, 0x300000, 0x7fc0000 });
		jj_expentries = new Vector();
		jj_kind = -1;
		jj_input_stream = new JavaCharStream(reader, 1, 1);
		token_source = new TagExportParserTokenManager(jj_input_stream);
		token = new Token();
		jj_ntk = -1;
		jj_gen = 0;
		for (int i = 0; i < 31; i++)
			jj_la1[i] = -1;

	}

	public TagExportParser(
			TagExportParserTokenManager tagexportparsertokenmanager) {
		jj_la1 = new int[31];
		jj_la1_0 = (new int[] { 0x8003e00, 128, 256, 9216, 6656, 0x8003e00,
				9216, 6656, 15872, 0x803c000, 128, 256, 49152, 0x30000,
				0x803c000, 49152, 0x30000, 0x3c000, 0xffc0000, 128, 256,
				0x6000000, 0x1c00000, 0xc0000, 0x300000, 0xffc0000, 0x6000000,
				0x1c00000, 0xc0000, 0x300000, 0x7fc0000 });
		jj_expentries = new Vector();
		jj_kind = -1;
		token_source = tagexportparsertokenmanager;
		token = new Token();
		jj_ntk = -1;
		jj_gen = 0;
		for (int i = 0; i < 31; i++)
			jj_la1[i] = -1;

	}

}
